Skip to content

Lint nested format_args! for uninlined args#16885

Open
lkirkwood wants to merge 1 commit intorust-lang:masterfrom
lkirkwood:master
Open

Lint nested format_args! for uninlined args#16885
lkirkwood wants to merge 1 commit intorust-lang:masterfrom
lkirkwood:master

Conversation

@lkirkwood
Copy link
Copy Markdown

@lkirkwood lkirkwood commented Apr 19, 2026

changelog: [uninlined_format_args]: Fix false negative on nested format_args! calls.

Previously a format_args! call or a macro marked clippy::format_args would not be linted for uninlined arguments when one of the arguments was in turn a format_args! call. This fixes point three of #16411.

An example:

#[clippy::format_args]
macro_rules! nested_format_args {
    ($($arg:tt)*) => {{
        // Wraps the user args in another format_args call
        ::core::format_args!("{}\n", ::core::format_args!($($arg)*))
    }};
}

fn nested_format_args_user() {
    let local_i32 = 1;
    let local_f64 = 2.0;

    nested_format_args!("{}", local_i32);
    //~^ uninlined_format_args
    nested_format_args!("val='{}'", local_i32);
    //~^ uninlined_format_args
    nested_format_args!("{:.1}", local_f64);
    //~^ uninlined_format_args
}

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Apr 19, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 19, 2026

r? @dswij

rustbot has assigned @dswij.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: 7 candidates
  • 7 candidates expanded to 7 candidates
  • Random selection from Jarcho, dswij, llogiq, samueltardieu

Previously a `format_args!` call or a macro marked `clippy::format_args`
would not be linted for uninlined arguments when one of the arguments
was in turn a `format_args!` call.
@github-actions
Copy link
Copy Markdown

Lintcheck changes for b54eb71

Lint Added Removed Changed
clippy::uninlined_format_args 3 0 0

This comment will be updated if you push new changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants